import instance from "./app";
//登录
export const loginApi = (userName, password) =>
  instance.post("/api/v1/auth/manager_login", {
    userName,
    password,
  });
//上传文件
export const uploadApi = (file) =>
  instance.post("/api/v1/common/upload_file", flie);
//商品分类
//所有商品分类
export const getProductCategoryApiAll = (per=100) =>
  instance({
    url: "/api/v1/admin/productcategory",params:{per}
  });
//获取商品分类列表
/*
export const getProductCategoryApi = (page = 1) =>
  instance({
    url: "/api/v1/admin/productcategory",
    params: {
      page,
    },
  }); 
  */
export const getProductCategoryApi = (page = 1, name = "") =>
  instance({ url: "/api/v1/admin/productcategory", params: { page, name } });
//删除商品分类列表
export const deleteProductCategoryApi = (id) =>
  instance.delete("/api/v1/admin/productcategory/" + id);
//新增商品分类列表
export const addProductCategoryApi = (data) =>
  instance.post("/api/v1/admin/productcategory", data);
//修改商品分类信息
export const putProductCategoryApi = (id, data) =>
  instance.put("/api/v1/admin/productcategory/" + id, data);
//商品
//获取一件商品详细信息
export const getShoppingDetail = (id) =>
  instance({ url: "/api/v1/products/" + id });
//获取商品列表
export const getProductApi = (page = 1, name = "", category = "") =>
  instance({ url: "/api/v1/admin/product", params: { page, name, category } });
//删除商品列表
export const deleteProductApi = (id) =>
  instance.delete("/api/v1/admin/product/" + id);
//新增商品列表
export const addProductApi = (data) =>
  instance.post("/api/v1/admin/product", data);
//修改商品信息
export const putProductApi = (id, data) =>
  instance.put("/api/v1/admin/product/" + id, data);
//获取论坛列表
export const getForumListAPI = (page = 1) =>
  instance({
    url: "/api/v1/admin/forum",
    params: {
      page,
    },
  });
// 增加论坛分类
export const addForumPlateAPI = (data) =>
  instance.post("/api/v1/admin/forum", data);
// 修改论坛分类
export const modifyForumPlateAPI = (id, data) =>
  instance.put("/api/v1/admin/forum/" + id, data);
// 删除论坛分类
export const delForumPlateAPI = (id) =>
  instance.delete("/api/v1/admin/forum/" + id);
//获取帖子列表
export const getPostApi = (page = 1, name = "", forum = "") =>
  instance({
    url: "/api/v1/admin/post",
    params: {
      page,
      name,
      forum,
    },
  });
//帖子审核
export const putPostCheckApi = (ids, isChecked) =>
  instance({
    url: "/api/v1/admin/post/" + ids,
    data: { isChecked },
    method: "put",
  });
//帖子删除
export const deletePostApi = (id) =>
  instance({ url: "/api/v1/admin/post/" + id, method: "delete" });
//添加帖子
export const addPostApi = (data) => instance.post("/api/v1/posts", data);
//帖子详情
export const getPortDetail = (id) => instance.get("/api/v1/posts/" + id);

// 获取活动分类列表
export const getActivityCategoryList = (page = 1) =>
  instance({
    url: "/api/v1/admin/activitycategory",
    params: {
      page,
    },
  });

//新增活动分类
export const addActivityCategoryList = (data) =>
  instance.post("/api/v1/admin/activitycategory", data);
//修改活动分类
export const modifyActivityCategoryList = (id) =>
  instance.put("/api/v1/admin/activitycategory/" + id);
//删除活动分类
export const delActivityCategoryList = (id) =>
  instance.delete("/api/v1/admin/activitycategory/" + id);

//获取活动列表
export const getActivityList = (page = 1, name = "", category = "") =>
  instance({
    url: "/api/v1/admin/activity",
    params: {
      page,
      name,
      category,
    },
  });

//增加活动
export const addActivityList = (data) =>
  instance.post("/api/v1/admin/activity", data);
// 修改活动
export const modifyActivityList = (id, data) =>
  instance.put("/api/v1/admin/activity/" + id, data);
// 删除活动
export const delActivityList = (id) =>
  instance.delete("/api/v1/admin/activity/" + id);
//获取详情
export const getActivityDetail = (activity = "", page = 1) =>
  instance({
    url: "/api/v1/admin/activity_log",
    params: {
      activity,
      page,
    },
  });
//获取轮播图分类列表
export const getSlideshowcategoryList = (page = 1) =>
  instance.get("/api/v1/admin/bannercategory", page);
//新增轮播图分类
export const addSlideshowcategoryList = (data) =>
  instance.post("/api/v1/admin/bannercategory", data);
//修改轮播图分类
export const modifySlideshowcategoryList = (id, data) =>
  instance.put("/api/v1/admin/bannercategory/" + id, data);

//删除轮播图分类
export const delSlideshowcategoryList = (id) =>
  instance.delete("/api/v1/admin/bannercategory/" + id);

//获取轮播图列表
export const getSlideshow = (page = 1, category = "") =>
  instance({
    url: "/api/v1/admin/banner",
    params: {
      page,
      category,
    },
  });
//新增轮播图
export const addSlideshow = (data) =>
  instance.post("/api/v1/admin/banner", data);
//修改轮播图
export const modifySlideshow = (id, data) =>
  instance.put("/api/v1/admin/banner/" + id, data);
//删除轮播图
export const delSlideshow = (id) =>
  instance.delete("/api/v1/admin/banner/" + id);
//获取用户列表
export const getUserList = (page = 1, userName = "", nickName = "") =>
  instance({
    url: "/api/v1/admin/user",
    params: {
      page,
      userName,
      nickName,
    },
  });
// 修改用户
export const modifyUser = (id, data) =>
  instance.put("/api/v1/admin/user/" + id, data);
// 删除用户
export const delUser = (id) => instance.delete("/api/v1/admin/user/" + id);
//锁定用户
export const lockUser = (ids, isLocked) =>
  instance.put({
    url: "/api/v1/admin/user/" + ids,
    data: { isLocked },
    method: "put",
  });

//用户购物车列表
export const getUserShop = (user) =>
  instance.get("/api/v1/admin/cart/info", user);
//用户购物车删除
export const delUsershop = (id) => instance.delete("/api/v1/admin/cart/" + id);
//积分记录
export const scoreLog = (user) =>
  instance.get("/api/v1/admin/scorelog/info", user);
